From 643449d8baf8c04fb83b2a4c9e7336c2ba885785 Mon Sep 17 00:00:00 2001 From: "robertlipe@gmail.com" Date: Sat, 26 Jan 2013 21:51:48 +0000 Subject: [PATCH] Make waypt_dupe act more like a copy constructor. git-svn-id: http://gpsbabel.googlecode.com/svn/trunk@4256 f51c46e8-681c-474f-0cfe-069cfd0219fb --- gpsbabel/waypt.cc | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/gpsbabel/waypt.cc b/gpsbabel/waypt.cc index f83bdcf05..5440749a9 100644 --- a/gpsbabel/waypt.cc +++ b/gpsbabel/waypt.cc @@ -44,18 +44,16 @@ waypt_init(void) QUEUE_INIT(&waypt_head); } +// This whole thing is a poor-man's copy constructor. It exists mostly +// as a bridge from our non-reference counted C types to classes now. waypoint * waypt_dupe(const waypoint *wpt) { /* * This and waypt_free should be closely synced. */ - waypoint * tmp; - url_link *url_next; - - tmp = waypt_new(); - memcpy(tmp, wpt, sizeof(waypoint)); - tmp->url_next = NULL; + waypoint* tmp = new waypoint; + *tmp = *wpt; if (wpt->shortname) { tmp->shortname = xstrdup(wpt->shortname); @@ -72,7 +70,8 @@ waypt_dupe(const waypoint *wpt) if (wpt->url_link_text) { tmp->url_link_text = xstrdup(wpt->url_link_text); } - for (url_next = wpt->url_next; url_next; url_next = url_next->url_next) { + + for (url_link* url_next = wpt->url_next; url_next; url_next = url_next->url_next) { waypt_add_url(tmp, (url_next->url) ? xstrdup(url_next->url) : NULL, (url_next->url_link_text) ? xstrdup(url_next->url_link_text) : NULL); @@ -239,9 +238,15 @@ void waypt_disp(const waypoint *wpt) { char *tmpdesc = NULL; +#if NEWTIME + if (wpt->creation_time.isValid()) { + printf("%s", qPrintable(wpt->creation_time.toString())); + } +#else if (wpt->creation_time) { printf("%s ", ctime(&wpt->creation_time)); } +#endif printposn(wpt->latitude,1); printposn(wpt->longitude,0); -- 2.30.2